package com.xyd.auth.security.custom;
import com.xyd.model.system.SysUser;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
import java.util.Collection;
// @Data 次注解在此处使用不合适，因为该类集成的父类中有属性以及get/set方法
public class CustomUser extends User {

    private SysUser sysUser;

    /**
     * 由于 父类 User 没有无参构造器 当前类必须写自己的构造器 ，并且第一行必须调用父级构造器
     * @param sysUser 传入的当前系统的用户实体类
     * @param authorities 用户权限集合
     */
    public CustomUser(SysUser sysUser, Collection<? extends GrantedAuthority> authorities) {
        super(sysUser.getUsername(), sysUser.getPassword(), authorities);
        this.sysUser = sysUser;
    }

    public SysUser getSysUser() {
        return sysUser;
    }

    public void setSysUser(SysUser sysUser) {
        this.sysUser = sysUser;
    }
}
